package com.xy.biz.rs.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.rs.domain.bo.ManufactureArchiveBO;
import com.xy.biz.rs.domain.po.ManufactureArchivePO;
import com.xy.biz.rs.domain.query.ManufactureArchiveQuery;
import com.xy.biz.rs.domain.resp.GetManufactureArchiveResponse;
import com.xy.biz.rs.domain.req.SaveManufactureArchiveRequest;
import com.xy.biz.rs.domain.req.ListManufactureArchiveRequest;

/**
 *
 *
 * @author wwj
 * @date 2021-4-19
 */
public class ManufactureArchiveConverter {

	public static ManufactureArchivePO toPO(ManufactureArchiveBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureArchivePO(), true);
	}

	public static List<ManufactureArchivePO> toPO(Collection<ManufactureArchiveBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureArchivePO(), true);
	}

	public static ManufactureArchiveBO fromPO(ManufactureArchivePO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureArchiveBO());
	}

	public static List<ManufactureArchiveBO> fromPO(Collection<ManufactureArchivePO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureArchiveBO());
	}

	public static ManufactureArchiveBO toBO(SaveManufactureArchiveRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureArchiveBO(), true);
	}

	public static List<ManufactureArchiveBO> toBO(Collection<SaveManufactureArchiveRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureArchiveBO(), true);
	}

	public static GetManufactureArchiveResponse toResponse(ManufactureArchiveBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetManufactureArchiveResponse());
	}

	public static List<GetManufactureArchiveResponse> toResponse(Collection<ManufactureArchiveBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetManufactureArchiveResponse());
	}

	public static ManufactureArchiveQuery toQuery(ListManufactureArchiveRequest source) {
		if(null == source) {
			return null;
		}
		ManufactureArchiveQuery target = new ManufactureArchiveQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
